package com.ymatou.iapi.productmanager.testcase;


import org.json.JSONObject;
import org.junit.After;
import org.junit.AfterClass;
import org.junit.Before;
import org.junit.BeforeClass;
import org.junit.Test;
import org.junit.experimental.categories.Category;

import com.ymatou.iapi.productmanager.service.QuerySellerProductStatisticsCall;
import com.ymt.core.tool.Logger;
import com.ymt.utils.annotation.TestCase;
import com.ymt.utils.tag.P1;
import com.ymttest.utils.EnvSetup;

public class Ts_QuerySellerProductStatistics {
	private static int sellerId = Integer.parseInt(EnvSetup.getData("productsellerid"));
	
	
	@BeforeClass
	public static void setUp() {
		Logger.createResultFile("商品销售状态统计");
	}

	@Before
	public void caseUp() {
	}

	@AfterClass
	public static void tearDown() {
		Logger.generateResult(new QuerySellerProductStatisticsCall().getOpurl());
	}
	
	
	@After
	public void caseDown() {
		Logger.end();
	}
	
	@Test
	@Category({P1.class})
	@TestCase
	public void Tc_QuerySellerProductStatistics_001() {
		Logger.start(true, "商品销售状态统计");
		try{
			JSONObject ret = new QuerySellerProductStatisticsCall().call(sellerId);
			Logger.verifyEquals(200, ret.getInt("Code"), "check return code");
			Logger.verifyEquals(false, ret.getJSONObject("Data").isNull("InSaleCount"), "InSaleCount");
			Logger.verifyEquals(false, ret.getJSONObject("Data").isNull("OutSaleCount"), "OutSaleCount");
			
			
			JSONObject ret2 = new QuerySellerProductStatisticsCall().call(sellerId+1);
			Logger.verifyEquals(200, ret2.getInt("Code"), "check return code");
			Logger.verifyEquals(false, ret2.getJSONObject("Data").isNull("InSaleCount"), "InSaleCount");
			Logger.verifyEquals(false, ret2.getJSONObject("Data").isNull("OutSaleCount"), "OutSaleCount");
		}catch(Exception e){
			Logger.fail(e);
		}
	}
	
}
